package com.bootdo.hjh.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.bootdo.hjh.service.WxPayService;
import com.wxpay.sdk.WXConfig;
import com.wxpay.sdk.WXPay;
@Service
public class WxPayServiceImpl implements WxPayService{

	@Override
	public Map<String, String> doPay(String title,String orderNo,String amount,String ip,String productId)throws Exception {
		HashMap<String, String> data = new HashMap<String, String>();
        data.put("body", title);
        data.put("out_trade_no", orderNo);
        data.put("device_info", "");
        data.put("fee_type", "CNY");
        data.put("total_fee", amount);
        data.put("spbill_create_ip", ip);
        data.put("notify_url", "http://www.meixiberry.com/order/wx/webhook");
        data.put("trade_type", "NATIVE");
        data.put("product_id", productId);
       
        // data.put("time_expire", "20170112104120");
        WXPay wxpay = new WXPay(WXConfig.getInstance());
        try {
            Map<String, String> r = wxpay.unifiedOrder(data);
            return r;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
	}

}
